using System.IO;
using System.Windows;
using ApprovalTests.Core;
using SmallBasicFun.Tracking;

namespace SmallBasicFun.Tests
{
	public class DispatchedWindowWpfWriter : IApprovalWriter
	{
		private readonly Window Window;

		public DispatchedWindowWpfWriter(Window window)
		{
			Window = window;
		}

		public string GetApprovalFilename(string basename)
		{
			return basename + ".approved.png";
		}

		public string GetReceivedFilename(string basename)
		{
			return basename + ".received.png";
		}

		public string WriteReceivedFile(string received)
		{
			using (var stream = File.Create(received))
			{
				ScreenCapture.DrawDispatchedWindow(Window, stream);
			}
			return received;
		}
	}
}